Skip to main content

Globbing

Extended globbing

Bash lets you use extended globbing, which allows more patterns. To use it you can do shopt -s extglob, which will enable it. The extended globbing allows you to apply operators to a certain list of patterns. For example, !(*.jpg|*.gif) will match everything that's not a gif or a jpg. The list of all features lays in the man bash, \"Pattern Matching\" section.

The '^' character

This character means the same as '!' (match what is not inside the brackets) but is not POSIX. Hence, if you use it in your shell (bash), it will have the desired behaviour, but inside a script called with sh, it will be undefined.